<?php

namespace app\admin\controller\finance;

use app\admin\model\UM as UM;
use app\admin\service\CompanyBillStatisticsService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * CompanyBillStatistics 控制器
 * Class CompanyBillStatistics
 * @package app\admin\controller\finance;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class CompanyBillStatistics
{
    // 请求参数
    private Request $request;

    // service
    private CompanyBillStatisticsService $service;

    public function __construct(Request $request, CompanyBillStatisticsService $companyBillStatisticsService)
    {
        $this->request = $request;
        $this->service = $companyBillStatisticsService;
    }

    /**
     * 详情
     * @param UM|null $user
     * @return ApiResponse
     * @url /finance/company_bill_statistics/read
     */
    public function read(UM $user): ApiResponse
    {
        $request = $this->request;

        $companyId = $request->param('companyId');
        $startTime = $request->param('startTime');
        $endTime = $request->param('endTime');

        return ApiResponse::success($this->service->read($user, $companyId, $startTime, $endTime));
    }

}
